package com.tanhua.dubbo.server.api;

import com.alibaba.dubbo.config.annotation.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tanhua.domain.db.BlackList;
import com.tanhua.domain.db.UserInfo;
import com.tanhua.dubbo.server.mapper.BlackListMapper;
import com.tanhua.dubbo.server.mapper.UserInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;

@Service
public class BlackListServiceImpl implements BlackListApi {

    @Autowired
    private BlackListMapper blackListMapper;

    @Autowired
    private UserInfoMapper userInfoMapper;

    public IPage<UserInfo> queryPageList(Long userId, Integer page, Integer pageSize) {
        Page<UserInfo> pager = new Page<>(page, pageSize);
        return userInfoMapper.selectUserPage(pager, userId);
    }

    public Boolean delBlacklist(Long userId, Long blackListUserId) {
        QueryWrapper<BlackList> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id", userId);
        queryWrapper.eq("black_user_id", blackListUserId);
        return this.blackListMapper.delete(queryWrapper) > 0;
    }
}
